/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package FamousBallet;

/**
 *<pre>
 File name  Ballet.java
 * @author    <b><i>Yerong</i></b>
 * Instructor  Niko Culevski
 * Class       CS 141 B
 * Due date    11/29/2016
 * Assignment  Project_3
 * @version   1.0.1
 * Platform    PC, Windows 10, NetBeans 8.1
 *******************************************************************************
* This class is a kind of structure of a Ballet object.
* A Ballet object has name, composer, city and year first performed, synopsis
* ,and link to Youtube.
* 
* Because this is a structure, all the variable should be accessable and modifi-
* -able.
 *******************************************************************************
 * Input:    name, composer, city, year, synopsis, and link of a ballet
 * Output:   The ballet object
 *******************************************************************************
 * </pre>
 */
public class Ballet {

    //Declearing all the attributions of a ballet object
    private String name, composer;
    String city,synopsis;
    String link;
    private int year;
    
    public Ballet(String name, String composer, int year, String city, String synopsis, String link) {
        this.name = name;
        this.composer = composer;
        this.city = city;
        this.synopsis = synopsis;
        this.link = link;
        this.year = year;
    }
    
    //Default constructor
    public Ballet(){
        
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setName()
     * Change the name of the ballet
     * @param name the name of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */       
    public void setName(String name) {
        this.name = name;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setComposer()
     * Change the composer of the ballet
     * @param composer the composer of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */         
    public void setComposer(String composer) {
        this.composer = composer;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setCity()
     * Change the city of the ballet
     * @param city the city of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */       
    public void setCity(String city) {
        this.city = city;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setSynopsis()
     * Change the synopsis of the ballet
     * @param synopsis the synopsis of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */       
    public void setSynopsis(String synopsis) {
        this.synopsis = synopsis;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setLink()
     * Change the link of the ballet
     * @param link the link of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */        
    public void setLink(String link) {
        this.link = link;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method setYear()
     * Change the year of the ballet
     * @param year the year of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */      
    public void setYear(int year) {
        this.year = year;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getName()
     * Get the name of the ballet
     * @return the name of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */       
    public String getName() {
        return name;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getComposer()
     * Get the composer of the ballet
     * @return the composer of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */        
    public String getComposer() {
        return composer;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getCity()
     * Get the city of the ballet
     * @return the city of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */      
    public String getCity() {
        return city;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getSynopsis()
     * Get the synopsis of the ballet
     * @return the synopsis of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */         
    public String getSynopsis() {
        return synopsis;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getLink()
     * Get the link of the ballet
     * @return the link of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */  
    public String getLink() {
        return link;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method getYear()
     * Get the year of the ballet
     * @return the year of the ballet
     * @author Yerong
     * Date: 11/29/2016
     */      
    public int getYear() {
        return year;
    }

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method divideLongString()
     * Divide long string texts in 50 columns per row.
     * @return Clear string with 50 columns per row
     * @param text, the input value
     * @author Yerong
     * Date: 11/29/2016
     */    
    public String divideLongString(String text){
        StringBuilder output = new StringBuilder();
        int lastPos = 0;
        for(int i=0;i+50<text.length();i+=50){
            output.append(text.substring(i, i+50)+"\n");
            lastPos=i+50;
        }
        output.append(text.substring(lastPos, text.length()));
        return output.toString();
    }
    
    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method toString()
     * Overrided toString method. This will return all the information in a 
     * string.
     * @return all the information about the ballet
     * @author Yerong
     * Date: 11/29/2016
     */     
    @Override
    public String toString() {
        return "Ballet name:\t" + name + "\nComposer:\t" + composer + 
                "\nYear first performed:\t" + year + 
                "\nCity first performed:\t" + city+ "\nSynopsis:\t" + 
                divideLongString(synopsis) + "\nLink to Youtube:\t" + link;
    }   

    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method toData()
     * This is used to make up the data file. The return value is arranged
     * in a special order.
     * @return Arranged information in a special order
     * @author Yerong
     * Date: 11/29/2016
     */ 
    public String toData(){
         return "~~" + name + "~~" + composer + "~~" + year + "~~" + city+ "~~" 
                 + synopsis + "~~" + link;   
    }
    
    /**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     * Method equals()
     * Overloaded equals method. This checks whether the compared object is 
     * the same as this object.
     * @return if the object is the same as this ballet
     * @param obj, the compared ballet object
     * @author Yerong
     * Date: 11/29/2016
     */       
    public boolean equals(Ballet obj) {
        //If this is totally the same as the object, return true
        if (this == obj) {
            return true;
        }
        
        //If the compared object is null, return false
        if (obj == null) {
            return false;
        }
        //If names, years, and composers are equal, return true
        if(this.name.equals(obj.getName())&&this.year==obj.getYear()&&
                this.composer.equals(obj.getComposer()))
            return true;

        return false;
    }
    
}
